1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module soup.Server; 26 27 private import gio.IOStream; 28 private import gio.Socket; 29 private import gio.SocketAddress; 30 private import glib.ConstructionException; 31 private import glib.ErrorG; 32 private import glib.GException; 33 private import glib.ListSG; 34 private import glib.MainContext; 35 private import glib.Str; 36 private import gobject.ObjectG; 37 private import gobject.Signals; 38 private import soup.AuthDomain; 39 private import soup.ClientContext; 40 private import soup.Message; 41 private import soup.SSocket; 42 private import soup.c.functions; 43 public import soup.c.types; 44 private import std.algorithm; 45 46 47 /** */ 48 public class Server : ObjectG 49 { 50 /** the main Gtk struct */ 51 protected SoupServer* soupServer; 52 53 /** Get the main Gtk struct */ 54 public SoupServer* getServerStruct(bool transferOwnership = false) 55 { 56 if (transferOwnership) 57 ownedRef = false; 58 return soupServer; 59 } 60 61 /** the main Gtk struct as a void* */ 62 protected override void* getStruct() 63 { 64 return cast(void*)soupServer; 65 } 66 67 /** 68 * Sets our main struct and passes it to the parent class. 69 */ 70 public this (SoupServer* soupServer, bool ownedRef = false) 71 { 72 this.soupServer = soupServer; 73 super(cast(GObject*)soupServer, ownedRef); 74 } 75 76 77 /** */ 78 public static GType getType() 79 { 80 return soup_server_get_type(); 81 } 82 83 /** 84 * Add a new client stream to the @server. 85 * 86 * Params: 87 * stream = a #GIOStream 88 * localAddr = the local #GSocketAddress associated with the @stream 89 * remoteAddr = the remote #GSocketAddress associated with the @stream 90 * 91 * Returns: %TRUE on success, %FALSE if the stream could not be 92 * accepted or any other error occurred (in which case @error will be 93 * set). 94 * 95 * Since: 2.50 96 * 97 * Throws: GException on failure. 98 */ 99 public bool acceptIostream(IOStream stream, SocketAddress localAddr, SocketAddress remoteAddr) 100 { 101 GError* err = null; 102 103 auto __p = soup_server_accept_iostream(soupServer, (stream is null) ? null : stream.getIOStreamStruct(), (localAddr is null) ? null : localAddr.getSocketAddressStruct(), (remoteAddr is null) ? null : remoteAddr.getSocketAddressStruct(), &err) != 0; 104 105 if (err !is null) 106 { 107 throw new GException( new ErrorG(err) ); 108 } 109 110 return __p; 111 } 112 113 /** 114 * Adds an authentication domain to @server. Each auth domain will 115 * have the chance to require authentication for each request that 116 * comes in; normally auth domains will require authentication for 117 * requests on certain paths that they have been set up to watch, or 118 * that meet other criteria set by the caller. If an auth domain 119 * determines that a request requires authentication (and the request 120 * doesn't contain authentication), @server will automatically reject 121 * the request with an appropriate status (401 Unauthorized or 407 122 * Proxy Authentication Required). If the request used the 123 * "100-continue" Expectation, @server will reject it before the 124 * request body is sent. 125 * 126 * Params: 127 * authDomain = a #SoupAuthDomain 128 */ 129 public void addAuthDomain(AuthDomain authDomain) 130 { 131 soup_server_add_auth_domain(soupServer, (authDomain is null) ? null : authDomain.getAuthDomainStruct()); 132 } 133 134 /** 135 * Adds an "early" handler to @server for requests under @path. Note 136 * that "normal" and "early" handlers are matched up together, so if 137 * you add a normal handler for "/foo" and an early handler for 138 * "/foo/bar", then a request to "/foo/bar" (or any path below it) 139 * will run only the early handler. (But if you add both handlers at 140 * the same path, then both will get run.) 141 * 142 * For requests under @path (that have not already been assigned a 143 * status code by a #SoupAuthDomain or a signal handler), @callback 144 * will be invoked after receiving the request headers, but before 145 * receiving the request body; the message's #SoupMessage:method and 146 * #SoupMessage:request-headers fields will be filled in. 147 * 148 * Early handlers are generally used for processing requests with 149 * request bodies in a streaming fashion. If you determine that the 150 * request will contain a message body, normally you would call 151 * soup_message_body_set_accumulate() on the message's 152 * #SoupMessage:request-body to turn off request-body accumulation, 153 * and connect to the message's #SoupMessage::got-chunk signal to 154 * process each chunk as it comes in. 155 * 156 * To complete the message processing after the full message body has 157 * been read, you can either also connect to #SoupMessage::got-body, 158 * or else you can register a non-early handler for @path as well. As 159 * long as you have not set the #SoupMessage:status-code by the time 160 * #SoupMessage::got-body is emitted, the non-early handler will be 161 * run as well. 162 * 163 * Params: 164 * path = the toplevel path for the handler 165 * callback = callback to invoke for requests under @path 166 * userData = data for @callback 167 * destroy = destroy notifier to free @user_data 168 * 169 * Since: 2.50 170 */ 171 public void addEarlyHandler(string path, SoupServerCallback callback, void* userData, GDestroyNotify destroy) 172 { 173 soup_server_add_early_handler(soupServer, Str.toStringz(path), callback, userData, destroy); 174 } 175 176 /** 177 * Adds a handler to @server for requests under @path. If @path is 178 * %NULL or "/", then this will be the default handler for all 179 * requests that don't have a more specific handler. (Note though that 180 * if you want to handle requests to the special "*" URI, you must 181 * explicitly register a handler for "*"; the default handler will not 182 * be used for that case.) 183 * 184 * For requests under @path (that have not already been assigned a 185 * status code by a #SoupAuthDomain, an early #SoupServerHandler, or a 186 * signal handler), @callback will be invoked after receiving the 187 * request body; the message's #SoupMessage:method, 188 * #SoupMessage:request-headers, and #SoupMessage:request-body fields 189 * will be filled in. 190 * 191 * After determining what to do with the request, the callback must at 192 * a minimum call soup_message_set_status() (or 193 * soup_message_set_status_full()) on the message to set the response 194 * status code. Additionally, it may set response headers and/or fill 195 * in the response body. 196 * 197 * If the callback cannot fully fill in the response before returning 198 * (eg, if it needs to wait for information from a database, or 199 * another network server), it should call soup_server_pause_message() 200 * to tell @server to not send the response right away. When the 201 * response is ready, call soup_server_unpause_message() to cause it 202 * to be sent. 203 * 204 * To send the response body a bit at a time using "chunked" encoding, 205 * first call soup_message_headers_set_encoding() to set 206 * %SOUP_ENCODING_CHUNKED on the #SoupMessage:response-headers. Then call 207 * soup_message_body_append() (or soup_message_body_append_buffer()) 208 * to append each chunk as it becomes ready, and 209 * soup_server_unpause_message() to make sure it's running. (The 210 * server will automatically pause the message if it is using chunked 211 * encoding but no more chunks are available.) When you are done, call 212 * soup_message_body_complete() to indicate that no more chunks are 213 * coming. 214 * 215 * Params: 216 * path = the toplevel path for the handler 217 * callback = callback to invoke for requests under @path 218 * userData = data for @callback 219 * destroy = destroy notifier to free @user_data 220 */ 221 public void addHandler(string path, SoupServerCallback callback, void* userData, GDestroyNotify destroy) 222 { 223 soup_server_add_handler(soupServer, Str.toStringz(path), callback, userData, destroy); 224 } 225 226 /** 227 * Add support for a WebSocket extension of the given @extension_type. 228 * When a WebSocket client requests an extension of @extension_type, 229 * a new #SoupWebsocketExtension of type @extension_type will be created 230 * to handle the request. 231 * 232 * You can also add support for a WebSocket extension to the server at 233 * construct time by using the %SOUP_SERVER_ADD_WEBSOCKET_EXTENSION property. 234 * Note that #SoupWebsocketExtensionDeflate is supported by default, use 235 * soup_server_remove_websocket_extension() if you want to disable it. 236 * 237 * Params: 238 * extensionType = a #GType 239 * 240 * Since: 2.68 241 */ 242 public void addWebsocketExtension(GType extensionType) 243 { 244 soup_server_add_websocket_extension(soupServer, extensionType); 245 } 246 247 /** 248 * Adds a WebSocket handler to @server for requests under @path. (If 249 * @path is %NULL or "/", then this will be the default handler for 250 * all requests that don't have a more specific handler.) 251 * 252 * When a path has a WebSocket handler registered, @server will check 253 * incoming requests for WebSocket handshakes after all other handlers 254 * have run (unless some earlier handler has already set a status code 255 * on the message), and update the request's status, response headers, 256 * and response body accordingly. 257 * 258 * If @origin is non-%NULL, then only requests containing a matching 259 * "Origin" header will be accepted. If @protocols is non-%NULL, then 260 * only requests containing a compatible "Sec-WebSocket-Protocols" 261 * header will be accepted. More complicated requirements can be 262 * handled by adding a normal handler to @path, and having it perform 263 * whatever checks are needed (possibly calling 264 * soup_server_check_websocket_handshake() one or more times), and 265 * setting a failure status code if the handshake should be rejected. 266 * 267 * Params: 268 * path = the toplevel path for the handler 269 * origin = the origin of the connection 270 * protocols = the protocols 271 * supported by this handler 272 * callback = callback to invoke for successful WebSocket requests under @path 273 * userData = data for @callback 274 * destroy = destroy notifier to free @user_data 275 */ 276 public void addWebsocketHandler(string path, string origin, string[] protocols, SoupServerWebsocketCallback callback, void* userData, GDestroyNotify destroy) 277 { 278 soup_server_add_websocket_handler(soupServer, Str.toStringz(path), Str.toStringz(origin), Str.toStringzArray(protocols), callback, userData, destroy); 279 } 280 281 /** 282 * Closes and frees @server's listening sockets. If you are using the 283 * old #SoupServer APIs, this also includes the effect of 284 * soup_server_quit(). 285 * 286 * Note that if there are currently requests in progress on @server, 287 * that they will continue to be processed if @server's #GMainContext 288 * is still running. 289 * 290 * You can call soup_server_listen(), etc, after calling this function 291 * if you want to start listening again. 292 */ 293 public void disconnect() 294 { 295 soup_server_disconnect(soupServer); 296 } 297 298 /** 299 * Gets @server's async_context, if you are using the old API. (With 300 * the new API, the server runs in the thread's thread-default 301 * #GMainContext, regardless of what this method returns.) 302 * 303 * This does not add a ref to the context, so you will need to ref it 304 * yourself if you want it to outlive its server. 305 * 306 * Deprecated: If you are using soup_server_listen(), etc, then 307 * the server listens on the thread-default #GMainContext, and this 308 * property is ignored. 309 * 310 * Returns: @server's #GMainContext, 311 * which may be %NULL 312 */ 313 public MainContext getAsyncContext() 314 { 315 auto __p = soup_server_get_async_context(soupServer); 316 317 if(__p is null) 318 { 319 return null; 320 } 321 322 return new MainContext(cast(GMainContext*) __p); 323 } 324 325 /** 326 * Gets @server's listening socket, if you are using the old API. 327 * 328 * You should treat this socket as read-only; writing to it or 329 * modifiying it may cause @server to malfunction. 330 * 331 * Deprecated: If you are using soup_server_listen(), etc, then use 332 * soup_server_get_listeners() to get a list of all listening sockets, 333 * but note that that function returns #GSockets, not #SoupSockets. 334 * 335 * Returns: the listening socket. 336 */ 337 public SSocket getListener() 338 { 339 auto __p = soup_server_get_listener(soupServer); 340 341 if(__p is null) 342 { 343 return null; 344 } 345 346 return ObjectG.getDObject!(SSocket)(cast(SoupSocket*) __p); 347 } 348 349 /** 350 * Gets @server's list of listening sockets. 351 * 352 * You should treat these sockets as read-only; writing to or 353 * modifiying any of these sockets may cause @server to malfunction. 354 * 355 * (Beware that in contrast to the old soup_server_get_listener(), this 356 * function returns #GSockets, not #SoupSockets.) 357 * 358 * Returns: a 359 * list of listening sockets. 360 */ 361 public ListSG getListeners() 362 { 363 auto __p = soup_server_get_listeners(soupServer); 364 365 if(__p is null) 366 { 367 return null; 368 } 369 370 return new ListSG(cast(GSList*) __p); 371 } 372 373 /** 374 * Gets the TCP port that @server is listening on, if you are using 375 * the old API. 376 * 377 * Deprecated: If you are using soup_server_listen(), etc, then use 378 * soup_server_get_uris() to get a list of all listening addresses. 379 * 380 * Returns: the port @server is listening on. 381 */ 382 public uint getPort() 383 { 384 return soup_server_get_port(soupServer); 385 } 386 387 /** 388 * Gets a list of URIs corresponding to the interfaces @server is 389 * listening on. These will contain IP addresses, not hostnames, and 390 * will also indicate whether the given listener is http or https. 391 * 392 * Note that if you used soup_server_listen_all(), the returned URIs 393 * will use the addresses <literal>0.0.0.0</literal> and 394 * <literal>::</literal>, rather than actually returning separate URIs 395 * for each interface on the system. 396 * 397 * Returns: a list of 398 * #SoupURIs, which you must free when you are done with it. 399 * 400 * Since: 2.48 401 */ 402 public ListSG getUris() 403 { 404 auto __p = soup_server_get_uris(soupServer); 405 406 if(__p is null) 407 { 408 return null; 409 } 410 411 return new ListSG(cast(GSList*) __p, true); 412 } 413 414 /** 415 * Checks whether @server is capable of https. 416 * 417 * In order for a server to run https, you must call 418 * soup_server_set_ssl_cert_file(), or set the 419 * #SoupServer:tls-certificate property, to provide it with a 420 * certificate to use. 421 * 422 * If you are using the deprecated single-listener APIs, then a return 423 * value of %TRUE indicates that the #SoupServer serves https 424 * exclusively. If you are using soup_server_listen(), etc, then a 425 * %TRUE return value merely indicates that the server is 426 * <emphasis>able</emphasis> to do https, regardless of whether it 427 * actually currently is or not. Use soup_server_get_uris() to see if 428 * it currently has any https listeners. 429 * 430 * Returns: %TRUE if @server is configured to serve https. 431 */ 432 public bool isHttps() 433 { 434 return soup_server_is_https(soupServer) != 0; 435 } 436 437 /** 438 * This attempts to set up @server to listen for connections on 439 * @address. 440 * 441 * If @options includes %SOUP_SERVER_LISTEN_HTTPS, and @server has 442 * been configured for TLS, then @server will listen for https 443 * connections on this port. Otherwise it will listen for plain http. 444 * 445 * You may call this method (along with the other "listen" methods) 446 * any number of times on a server, if you want to listen on multiple 447 * ports, or set up both http and https service. 448 * 449 * After calling this method, @server will begin accepting and 450 * processing connections as soon as the appropriate #GMainContext is 451 * run. 452 * 453 * Note that #SoupServer never makes use of dual IPv4/IPv6 sockets; if 454 * @address is an IPv6 address, it will only accept IPv6 connections. 455 * You must configure IPv4 listening separately. 456 * 457 * Params: 458 * address = the address of the interface to listen on 459 * options = listening options for this server 460 * 461 * Returns: %TRUE on success, %FALSE if @address could not be 462 * bound or any other error occurred (in which case @error will be 463 * set). 464 * 465 * Since: 2.48 466 * 467 * Throws: GException on failure. 468 */ 469 public bool listen(SocketAddress address, SoupServerListenOptions options) 470 { 471 GError* err = null; 472 473 auto __p = soup_server_listen(soupServer, (address is null) ? null : address.getSocketAddressStruct(), options, &err) != 0; 474 475 if (err !is null) 476 { 477 throw new GException( new ErrorG(err) ); 478 } 479 480 return __p; 481 } 482 483 /** 484 * This attempts to set up @server to listen for connections on all 485 * interfaces on the system. (That is, it listens on the addresses 486 * <literal>0.0.0.0</literal> and/or <literal>::</literal>, depending 487 * on whether @options includes %SOUP_SERVER_LISTEN_IPV4_ONLY, 488 * %SOUP_SERVER_LISTEN_IPV6_ONLY, or neither.) If @port is specified, 489 * @server will listen on that port. If it is 0, @server will find an 490 * unused port to listen on. (In that case, you can use 491 * soup_server_get_uris() to find out what port it ended up choosing.) 492 * 493 * See soup_server_listen() for more details. 494 * 495 * Params: 496 * port = the port to listen on, or 0 497 * options = listening options for this server 498 * 499 * Returns: %TRUE on success, %FALSE if @port could not be bound 500 * or any other error occurred (in which case @error will be set). 501 * 502 * Since: 2.48 503 * 504 * Throws: GException on failure. 505 */ 506 public bool listenAll(uint port, SoupServerListenOptions options) 507 { 508 GError* err = null; 509 510 auto __p = soup_server_listen_all(soupServer, port, options, &err) != 0; 511 512 if (err !is null) 513 { 514 throw new GException( new ErrorG(err) ); 515 } 516 517 return __p; 518 } 519 520 /** 521 * This attempts to set up @server to listen for connections on 522 * @fd. 523 * 524 * See soup_server_listen() for more details. 525 * 526 * Note that @server will close @fd when you free it or call 527 * soup_server_disconnect(). 528 * 529 * Params: 530 * fd = the file descriptor of a listening socket 531 * options = listening options for this server 532 * 533 * Returns: %TRUE on success, %FALSE if an error occurred (in 534 * which case @error will be set). 535 * 536 * Since: 2.48 537 * 538 * Throws: GException on failure. 539 */ 540 public bool listenFd(int fd, SoupServerListenOptions options) 541 { 542 GError* err = null; 543 544 auto __p = soup_server_listen_fd(soupServer, fd, options, &err) != 0; 545 546 if (err !is null) 547 { 548 throw new GException( new ErrorG(err) ); 549 } 550 551 return __p; 552 } 553 554 /** 555 * This attempts to set up @server to listen for connections on 556 * "localhost" (that is, <literal>127.0.0.1</literal> and/or 557 * <literal>::1</literal>, depending on whether @options includes 558 * %SOUP_SERVER_LISTEN_IPV4_ONLY, %SOUP_SERVER_LISTEN_IPV6_ONLY, or 559 * neither). If @port is specified, @server will listen on that port. 560 * If it is 0, @server will find an unused port to listen on. (In that 561 * case, you can use soup_server_get_uris() to find out what port it 562 * ended up choosing.) 563 * 564 * See soup_server_listen() for more details. 565 * 566 * Params: 567 * port = the port to listen on, or 0 568 * options = listening options for this server 569 * 570 * Returns: %TRUE on success, %FALSE if @port could not be bound 571 * or any other error occurred (in which case @error will be set). 572 * 573 * Since: 2.48 574 * 575 * Throws: GException on failure. 576 */ 577 public bool listenLocal(uint port, SoupServerListenOptions options) 578 { 579 GError* err = null; 580 581 auto __p = soup_server_listen_local(soupServer, port, options, &err) != 0; 582 583 if (err !is null) 584 { 585 throw new GException( new ErrorG(err) ); 586 } 587 588 return __p; 589 } 590 591 /** 592 * This attempts to set up @server to listen for connections on 593 * @socket. 594 * 595 * See soup_server_listen() for more details. 596 * 597 * Params: 598 * socket = a listening #GSocket 599 * options = listening options for this server 600 * 601 * Returns: %TRUE on success, %FALSE if an error occurred (in 602 * which case @error will be set). 603 * 604 * Since: 2.48 605 * 606 * Throws: GException on failure. 607 */ 608 public bool listenSocket(Socket socket, SoupServerListenOptions options) 609 { 610 GError* err = null; 611 612 auto __p = soup_server_listen_socket(soupServer, (socket is null) ? null : socket.getSocketStruct(), options, &err) != 0; 613 614 if (err !is null) 615 { 616 throw new GException( new ErrorG(err) ); 617 } 618 619 return __p; 620 } 621 622 /** 623 * Pauses I/O on @msg. This can be used when you need to return from 624 * the server handler without having the full response ready yet. Use 625 * soup_server_unpause_message() to resume I/O. 626 * 627 * This must only be called on #SoupMessages which were created by the 628 * #SoupServer and are currently doing I/O, such as those passed into a 629 * #SoupServerCallback or emitted in a #SoupServer::request-read signal. 630 * 631 * Params: 632 * msg = a #SoupMessage associated with @server. 633 */ 634 public void pauseMessage(Message msg) 635 { 636 soup_server_pause_message(soupServer, (msg is null) ? null : msg.getMessageStruct()); 637 } 638 639 /** 640 * Stops processing for @server, if you are using the old API. Call 641 * this to clean up after soup_server_run_async(), or to terminate a 642 * call to soup_server_run(). 643 * 644 * Note that messages currently in progress will continue to be 645 * handled, if the main loop associated with the server is resumed or 646 * kept running. 647 * 648 * @server is still in a working state after this call; you can start 649 * and stop a server as many times as you want. 650 * 651 * Deprecated: When using soup_server_listen(), etc, the server will 652 * always listen for connections, and will process them whenever the 653 * thread-default #GMainContext is running. 654 */ 655 public void quit() 656 { 657 soup_server_quit(soupServer); 658 } 659 660 /** 661 * Removes @auth_domain from @server. 662 * 663 * Params: 664 * authDomain = a #SoupAuthDomain 665 */ 666 public void removeAuthDomain(AuthDomain authDomain) 667 { 668 soup_server_remove_auth_domain(soupServer, (authDomain is null) ? null : authDomain.getAuthDomainStruct()); 669 } 670 671 /** 672 * Removes all handlers (early and normal) registered at @path. 673 * 674 * Params: 675 * path = the toplevel path for the handler 676 */ 677 public void removeHandler(string path) 678 { 679 soup_server_remove_handler(soupServer, Str.toStringz(path)); 680 } 681 682 /** 683 * Removes support for WebSocket extension of type @extension_type (or any subclass of 684 * @extension_type) from @server. You can also remove extensions enabled by default 685 * from the server at construct time by using the %SOUP_SERVER_REMOVE_WEBSOCKET_EXTENSION 686 * property. 687 * 688 * Params: 689 * extensionType = a #GType 690 * 691 * Since: 2.68 692 */ 693 public void removeWebsocketExtension(GType extensionType) 694 { 695 soup_server_remove_websocket_extension(soupServer, extensionType); 696 } 697 698 /** 699 * Starts @server, if you are using the old API, causing it to listen 700 * for and process incoming connections. Unlike 701 * soup_server_run_async(), this creates a #GMainLoop and runs it, and 702 * it will not return until someone calls soup_server_quit() to stop 703 * the server. 704 * 705 * Deprecated: When using soup_server_listen(), etc, the server will 706 * always listen for connections, and will process them whenever the 707 * thread-default #GMainContext is running. 708 */ 709 public void run() 710 { 711 soup_server_run(soupServer); 712 } 713 714 /** 715 * Starts @server, if you are using the old API, causing it to listen 716 * for and process incoming connections. 717 * 718 * The server runs in @server's #GMainContext. It will not actually 719 * perform any processing unless the appropriate main loop is running. 720 * In the simple case where you did not set the server's 721 * %SOUP_SERVER_ASYNC_CONTEXT property, this means the server will run 722 * whenever the glib main loop is running. 723 * 724 * Deprecated: When using soup_server_listen(), etc, the server will 725 * always listen for connections, and will process them whenever the 726 * thread-default #GMainContext is running. 727 */ 728 public void runAsync() 729 { 730 soup_server_run_async(soupServer); 731 } 732 733 /** 734 * Sets @server up to do https, using the SSL/TLS certificate 735 * specified by @ssl_cert_file and @ssl_key_file (which may point to 736 * the same file). 737 * 738 * Alternatively, you can set the #SoupServer:tls-certificate property 739 * at construction time, if you already have a #GTlsCertificate. 740 * 741 * Params: 742 * sslCertFile = path to a file containing a PEM-encoded SSL/TLS 743 * certificate. 744 * sslKeyFile = path to a file containing a PEM-encoded private key. 745 * 746 * Returns: success or failure. 747 * 748 * Since: 2.48 749 * 750 * Throws: GException on failure. 751 */ 752 public bool setSslCertFile(string sslCertFile, string sslKeyFile) 753 { 754 GError* err = null; 755 756 auto __p = soup_server_set_ssl_cert_file(soupServer, Str.toStringz(sslCertFile), Str.toStringz(sslKeyFile), &err) != 0; 757 758 if (err !is null) 759 { 760 throw new GException( new ErrorG(err) ); 761 } 762 763 return __p; 764 } 765 766 /** 767 * Resumes I/O on @msg. Use this to resume after calling 768 * soup_server_pause_message(), or after adding a new chunk to a 769 * chunked response. 770 * 771 * I/O won't actually resume until you return to the main loop. 772 * 773 * This must only be called on #SoupMessages which were created by the 774 * #SoupServer and are currently doing I/O, such as those passed into a 775 * #SoupServerCallback or emitted in a #SoupServer::request-read signal. 776 * 777 * Params: 778 * msg = a #SoupMessage associated with @server. 779 */ 780 public void unpauseMessage(Message msg) 781 { 782 soup_server_unpause_message(soupServer, (msg is null) ? null : msg.getMessageStruct()); 783 } 784 785 /** 786 * Emitted when processing has failed for a message; this 787 * could mean either that it could not be read (if 788 * #SoupServer::request_read has not been emitted for it yet), 789 * or that the response could not be written back (if 790 * #SoupServer::request_read has been emitted but 791 * #SoupServer::request_finished has not been). 792 * 793 * @message is in an undefined state when this signal is 794 * emitted; the signal exists primarily to allow the server to 795 * free any state that it may have allocated in 796 * #SoupServer::request_started. 797 * 798 * Params: 799 * message = the message 800 * client = the client context 801 */ 802 gulong addOnRequestAborted(void delegate(Message, ClientContext, Server) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 803 { 804 return Signals.connect(this, "request-aborted", dlg, connectFlags ^ ConnectFlags.SWAPPED); 805 } 806 807 /** 808 * Emitted when the server has finished writing a response to 809 * a request. 810 * 811 * Params: 812 * message = the message 813 * client = the client context 814 */ 815 gulong addOnRequestFinished(void delegate(Message, ClientContext, Server) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 816 { 817 return Signals.connect(this, "request-finished", dlg, connectFlags ^ ConnectFlags.SWAPPED); 818 } 819 820 /** 821 * Emitted when the server has successfully read a request. 822 * @message will have all of its request-side information 823 * filled in, and if the message was authenticated, @client 824 * will have information about that. This signal is emitted 825 * before any (non-early) handlers are called for the message, 826 * and if it sets the message's #status_code, then normal 827 * handler processing will be skipped. 828 * 829 * Params: 830 * message = the message 831 * client = the client context 832 */ 833 gulong addOnRequestRead(void delegate(Message, ClientContext, Server) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 834 { 835 return Signals.connect(this, "request-read", dlg, connectFlags ^ ConnectFlags.SWAPPED); 836 } 837 838 /** 839 * Emitted when the server has started reading a new request. 840 * @message will be completely blank; not even the 841 * Request-Line will have been read yet. About the only thing 842 * you can usefully do with it is connect to its signals. 843 * 844 * If the request is read successfully, this will eventually 845 * be followed by a #SoupServer::request_read signal. If a 846 * response is then sent, the request processing will end with 847 * a #SoupServer::request_finished signal. If a network error 848 * occurs, the processing will instead end with 849 * #SoupServer::request_aborted. 850 * 851 * Params: 852 * message = the new message 853 * client = the client context 854 */ 855 gulong addOnRequestStarted(void delegate(Message, ClientContext, Server) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 856 { 857 return Signals.connect(this, "request-started", dlg, connectFlags ^ ConnectFlags.SWAPPED); 858 } 859 }